package 华为机试8月23日;

import java.util.Scanner;

public class 华为第三题1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String s = sc.nextLine();
            System.out.println(func(s));
        }
        sc.close();
    }

    private static String func(String s) {
        String[] a = s.split("\\s+");
        int sradix = Integer.parseInt(a[0]);
        int dradix = Integer.parseInt(a[1]);
        String s1 = Integer.toString(Integer.parseInt(a[2], sradix), dradix);
        return s1.replaceAll("^[0]+", "");
    }
}
